package com.hg.design.structure.adapter.mine;

public class ChinaLaptop {
    private Power power;

    public ChinaLaptop(Power power) {
        if (power.getVoltage() == 220) {
            this.power = new ChinaPower();
        } else if (power.getVoltage() == 110) {
            this.power = new AmericaAdapter();
        } else {
            System.out.println("找不到相应的适配器");
        }
    }

    public void open(){
        this.power.plugIn();
        System.out.println("开机成功");
    }
}
